<?php


namespace App\Model;

use Illuminate\Database\Eloquent\Model;


class Webs  extends Model {
    protected $table = 'webs';
    protected $primaryKey = 'id';
    protected $dates = [
        'created_at',
        'updated_at',
    ];

    public static function getWebList($cate_id){
        $cateInfo = Category::getInfo($cate_id);
        if(!empty($cateInfo["list"])){
            return Webs::where(['status'=>1])
                ->whereIn("cate_id",array_column($cateInfo["list"],'id'))
                ->orderBy('sort', 'asc')
                ->get()
                ->toArray();
        }
        return Webs::where(['status'=>1,'cate_id'=>$cate_id])
            ->orderBy('sort', 'asc')
            ->get()
            ->toArray();
    }
}
